package com.zoz.constant;

import java.util.HashMap;
import java.util.Map;

/**
 * 数据库常用常量
 *@author zhuhg
 *@date 2020年6月4日 下午3:30:06
 */
public class DatabaseConstant {

	/**
	 * 查询所有的数据库
	 */
	public static final String DATABASE_ALL_SQL = "SELECT SCHEMA_NAME FROM information_schema.SCHEMATA s where s.SCHEMA_NAME not in ('information_schema','mysql','performance_schema','sys')";
	/**
	 * 查询数据库所有表名
	 */
	public static final String TABLE_ALL_SQL="select table_name as \"table_name\",table_comment as \"table_comment\" from information_schema.tables where table_schema = ?";
	/**
	 * 查询当前数据库表名的所有列属性
	 */
	public static final String TABLE_COLUM_TYPE_SQL = "select column_name as \"column_name\",column_comment as \"column_comment\",data_type as \"data_type\",is_nullable as \"is_nullable\" ,"
			+ "column_default as \"column_default\",'Y' AS \"table\",'Y' as \"save\",'Y' as \"update\",'Y' as \"select\" ,'N' as \"delete\" from information_schema.columns where table_name=? and table_schema=? order by ordinal_position";
	/**
	 * 数据库属性转换
	 */
	public static final Map<String,String> TYPE_MAP = new HashMap<>();
	/**
	 * xml映射类型
	 */
	public static final Map<String,String> JDBC_TYPE_MAP = new HashMap<>();
	/**
	 * 增加方法不包含列
	 */
	public static final Map<String,String> ADD_MAP = new HashMap<>();
	/**
	 * 修改方法不包含列
	 */
	public static final Map<String,String> UPDATE_MAP = new HashMap<>();
	/**
	 * 删除/作废方法包含列
	 */
	public static final Map<String,String> DELETE_MAP = new HashMap<>();
	
	
	static {

		TYPE_MAP.put("tinyint", "Integer");
		TYPE_MAP.put("smallint", "Integer");
		TYPE_MAP.put("mediumint", "Integer");
		TYPE_MAP.put("integer", "Integer");
		TYPE_MAP.put("int", "Integer");
		TYPE_MAP.put("bigint", "Long");
		TYPE_MAP.put("float", "Float");
		TYPE_MAP.put("double", "BigDecimal");
		TYPE_MAP.put("decimal", "BigDecimal");
		TYPE_MAP.put("number", "BigDecimal");
		TYPE_MAP.put("bit", "Boolean");
		TYPE_MAP.put("char", "String");
		TYPE_MAP.put("varchar", "String");
		TYPE_MAP.put("tinytext", "String");
		TYPE_MAP.put("text", "String");
		TYPE_MAP.put("mediumtext", "String");
		TYPE_MAP.put("longtext", "String");
		TYPE_MAP.put("datetime", "Date");
		TYPE_MAP.put("date", "Date");
		JDBC_TYPE_MAP.put("date", "TEMPSTAMP");
		JDBC_TYPE_MAP.put("tinyint", "INTEGER");
		JDBC_TYPE_MAP.put("smallint", "INTEGER");
		JDBC_TYPE_MAP.put("mediumint", "INTEGER");
		JDBC_TYPE_MAP.put("integer", "INTEGER");
		JDBC_TYPE_MAP.put("int", "INTEGER");
		JDBC_TYPE_MAP.put("bigint", "BIGINT");
		JDBC_TYPE_MAP.put("double", "DECIMAL");
		JDBC_TYPE_MAP.put("decimal", "DECIMAL");
		JDBC_TYPE_MAP.put("number", "DECIMAL");
		JDBC_TYPE_MAP.put("char", "CHAR");
		JDBC_TYPE_MAP.put("varchar", "VARCHAR");
		JDBC_TYPE_MAP.put("tinytext", "VARCHAR");
		JDBC_TYPE_MAP.put("text", "VARCHAR");
		JDBC_TYPE_MAP.put("mediumtext", "VARCHAR");
		JDBC_TYPE_MAP.put("longtext", "VARCHAR");
		JDBC_TYPE_MAP.put("datetime", "DATE");
		JDBC_TYPE_MAP.put("date", "DATE");
		ADD_MAP.put("id", "id");
		ADD_MAP.put("update_time", "update_time");
		ADD_MAP.put("update_user", "update_user");
		ADD_MAP.put("update_corp", "update_corp");
		ADD_MAP.put("yn", "yn");
		UPDATE_MAP.put("id", "id");
		UPDATE_MAP.put("create_time", "create_time");
		UPDATE_MAP.put("create_user", "create_user");
		UPDATE_MAP.put("create_corp", "create_corp");
		DELETE_MAP.put("yn", "yn");
		DELETE_MAP.put("update_time", "update_time");
		DELETE_MAP.put("update_user", "update_user");
		DELETE_MAP.put("update_corp", "update_corp");
	}
}
